cc.Class({
    extends: cc.Component,
    properties: {
        iconImageArray: {
            default: [],
            type: cc.SpriteFrame
        },
        currentMiniGameList: [],
        nextIndex: 0,
        moreGameList: [],
        settimeout: null,
        childIndex: -1
    },
    start: function () {
        this.initData(), this.initYouLike();
    },
    initData: function () {
        this.miniGameList = ["小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID", "小游戏APPID"];
        var t = cc.sys.localStorage.getItem("localMiniGameList_test15");
        if (t) {
            var e = JSON.parse(t);
            this.currentMiniGameList = e;
        } else this.currentMiniGameList = [0, 1, 2, 3];
        var n = cc.sys.localStorage.getItem("localNextIndex_test15");
        this.nextIndex = n ? parseInt(n) : 4;
    },
    initYouLike: function () {
        for (var t = this, e = 0; e < this.node.childrenCount; e++) {
            var n = this.node.children[e];
            n.getComponent(cc.Sprite).spriteFrame = this.iconImageArray[this.currentMiniGameList[e]],
                n.hasEventListener("touchstart") || n.on("touchstart", function () {
                    t.childIndex = this.getSiblingIndex(), t.settimeout && clearTimeout(t.settimeout),
                        t.settimeout = setTimeout(t.setTimeoutFun.bind(t), 2e3), wx.navigateToMiniProgram && wx.navigateToMiniProgram({
                            appId: t.miniGameList[t.currentMiniGameList[t.childIndex]],
                            path: ""
                        });
                }, n);
        }
    },
    setTimeoutFun: function () {
        this.currentIndex = this.nextIndex % this.miniGameList.length;
        for (var t = 0; t < this.currentMiniGameList.length; t++) this.currentMiniGameList.indexOf(this.currentIndex) >= 0 && (this.nextIndex++,
            this.currentIndex = this.nextIndex % this.miniGameList.length);
        this.currentMiniGameList[this.childIndex] = this.currentIndex, this.initYouLike(),
            cc.sys.localStorage.setItem("localMiniGameList_test15", JSON.stringify(this.currentMiniGameList)),
            cc.sys.localStorage.setItem("localNextIndex_test15", this.nextIndex.toString());
    }
})